﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using FwProject.Settlement.Dto
@using X.PagedList.Mvc.Common;
@model IPagedList<ReceiptFastlyDto>
@{
    Layout = null;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
    decimal Sumprice = 0;
}
<div style="max-height:600px;overflow-y:scroll;">
    <form class="form-horizontal" id="form1" asp-controller="Receipt" asp-action="QuickReceipt" data-ajax="true" data-ajax-method="Post" data-ajax-mode="replace" data-ajax-success="ReloadAjaxCallbackgoback" data-ajax-failure="FailureAjaxCallback">
        <table class="table table-bordered table-hover table-rowselected">
            <thead>
                <tr>
                    <th style="width:45px">序号</th>
                    <th>餐厅名称</th>
                    <th>应收金额</th>
                    <th>预收款余额</th>
                    <th>收款人</th>
                    <th>账户</th>
                    <th>本次收款</th>
                    <th>使用预收款</th>
                    <th>优惠金额</th>
                </tr>
            </thead>
            <tbody>
                @if (Model.Count == 0)
                {
                    <tr><td colspan="9" align="center">暂无数据</td></tr>
                }
                else
                {
                    int j = 0;
                    foreach (var item in Model)
                    {
                        i++;
                        Sumprice += item.TotalPrice;
                        <tr>
                            <td>@i</td>
                            <td><a href="javascript:top.window.openTab(1475,'应收明细【@item.RestaurantName】','/Receipt/ReceivableDetails?id=@item.RestaurantId')">@item.RestaurantName</a></td>
                            <td>@item.TotalPrice</td>
                            <td>@item.PrePaymentBalance</td>
                            <td>
                                <select name="QuickReceipts[@j].AgentPeoperUserId" class="form-control">
                                    @foreach (var u in ViewBag.User)
                                    {
                                        <option value="@u.Id">@u.Name</option>
                                    }
                                </select>
                            </td>
                            <td>
                                <select name="QuickReceipts[@j].CapitalAccountId" class="form-control">
                                    @foreach (var a in ViewBag.Account)
                                    {
                                        <option value="@a.Id">@a.Name</option>
                                    }
                                </select>
                            </td>
                            <td>
                                <input type="hidden" name="QuickReceipts[@j].RestaurantId" value="@item.RestaurantId" />
                                <input type="hidden" name="QuickReceipts[@j].WholeAmount" value="@item.TotalPrice" />
                                <input type="hidden" name="QuickReceipts[@j].ActualAmount" value="@item.TotalPrice" />
                                <input type="hidden" name="QuickReceipts[@j].PrePayment" value="@item.PrePaymentBalance" />
                                <input type="text" name="QuickReceipts[@j].TaskBackAmount" data-name="taskBackAmount" value="0" oninput="setPrice(this)" class="input-sm form-control" />
                            </td>
                            <td>
                                <input type="text" name="QuickReceipts[@j].UsePrePayment" data-name="usePrePayment" value="0" oninput="setPrice(this)" class="input-sm form-control" />
                            </td>
                            <td>
                                <input type="text" name="QuickReceipts[@j].PreferentialAmount" data-name="preferentialAmount" @(item.TotalPrice < 0 ? "readonly='readonly'" : "") value="0" oninput="setPrice(this)" class="input-sm form-control" />
                            </td>
                        </tr>
                        j++;
                    }
                    <tr class="footer">
                        <td>合计</td>
                        <td></td>
                        <td>@Sumprice</td>
                        <td colspan="6"></td>
                    </tr>
                }
            </tbody>
        </table>
    </form>
</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select> &nbsp; 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&RestaurantName=@(Context.Request.Query["RestaurantName"])&BalanceWay=@(Context.Request.Query["BalanceWay"])&BalanceCycle=@(Context.Request.Query["BalanceCycle"])" />
        @Html.PagedListPager(Model, page => Url.Action("FastlyReceipt", new { pageIdx = page, size = Context.Request.Query["size"], RestaurantName = Context.Request.Query["RestaurantName"], BalanceWay = Context.Request.Query["BalanceWay"], BalanceCycle = Context.Request.Query["BalanceCycle"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>

